package com.kongjs.application.properties;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.annotation.PropertySources;
import org.springframework.stereotype.Component;

import java.time.Duration;

@Slf4j
@Getter
@Setter
@ToString
@Component
/*@PropertySources({
        @PropertySource(name = "docker", value = "file:docker.yml", encoding = "UTF-8", factory = YamlPropertySourceFactory.class, ignoreResourceNotFound = true),
        @PropertySource(name = "docker", value = "file:docker.yaml", encoding = "UTF-8", factory = YamlPropertySourceFactory.class, ignoreResourceNotFound = true)
})*/
@ConfigurationProperties(prefix = "docker")
public class DockerProperties implements InitializingBean {
    private String dockerHost;
    private String apiVersion;
    private String registryUsername;
    private String registryPassword;
    private String registryEmail;
    private String registryUrl;
    private String dockerConfig;
    private String dockerCertPath;
    private String dockerContext;
    private Boolean dockerTlsVerify;
    private Integer maxConnections = 100;
    private Duration connectionTimeout = Duration.ofSeconds(15);
    private Duration responseTimeout = Duration.ofSeconds(15);

    @Override
    public void afterPropertiesSet() throws Exception {
        log.info("{}", this);
    }
}
